'use strict';
/*
 * 莫凡服务端接口 router
 * 云应用路由
 */
module.exports = app => {
  const { router, controller } = app;


  // 登陆接口
  router.post('/morefun/login', controller.login.token);
  router.get('/morefun/token', controller.login.tokenCheck);

  // 一般接口
  // POST 接口
  // morefun 示例和公共接口
  router.post('/:env/api/v1/testPost', controller.demo.testPost);
  // GET 接口
  router.get('/:env/api/v1/test', controller.demo.test);

  //admin用户
  router.post('/:env/api/v1/user/insert', controller.user.insert);
  router.get('/:env/api/v1/user/findOne', controller.user.findOne);
  router.get('/:env/api/v1/user/findAll', controller.user.findAll);
  //模板
  router.post('/:env/api/v1/template/insert', controller.template.insert);
  router.get('/:env/api/v1/template/findAll', controller.template.findAll);
  router.post('/:env/api/v1/template/update', controller.template.update);
  router.post('/:env/api/v1/template/delete', controller.template.delete);
  // 示图数据
  router.post('/:env/api/v1/view/insert', controller.view.insert);
  router.get('/:env/api/v1/view/findAll', controller.view.findAll);
  router.get('/:env/api/v1/view/findOne', controller.view.findOne);
  router.post('/:env/api/v1/view/update', controller.view.update);
  router.post('/:env/api/v1/view/delete', controller.view.delete);
  router.get('/:env/api/v1/view/selectAll', controller.view.selectAll);
  
  // 实例化模板
  router.post('/:env/api/v1/instantiation/insert', controller.instantiation.insert);
  router.get('/:env/api/v1/instantiation/findAll', controller.instantiation.findAll);
  router.post('/:env/api/v1/instantiation/update', controller.instantiation.update);
  router.post('/:env/api/v1/instantiation/delete', controller.instantiation.delete);
  router.post('/:env/api/v1/instantiation/onlineapp', controller.instantiation.onlineapp);
  
  // 实例化模板
  router.post('/:env/api/v1/association/insert', controller.associationLog.insert);
  router.get('/:env/api/v1/association/findAll', controller.associationLog.findAll);
  router.post('/:env/api/v1/association/update', controller.associationLog.update);
  router.post('/:env/api/v1/association/delete', controller.associationLog.delete);
  router.post('/:env/api/v1/association/release', controller.associationLog.release);

  

  // 组件化模块
  // 测试接口
  router.get('/:env/api/v1/mfutil/test', controller.mfutil.test);
  // 测试接口
  router.post('/:env/api/v1/mfutil/testPost', controller.mfutil.testPost);


  // 组件化模块自由扩展
  router.resources('mfutil_02', '/:env/api/v1/mfutil_02', controller.mfutil_02);
};
